# @Time    :2025/3/31 19:42
"""
通过面向对象的方式实现 朋友间的复杂关系

"""


class Student:
    def __init__(self, name, age):
        self.name = name
        self.age = age
        self.__bf = None  # 不是大家都具有的 就设为None

    @property
    def bf(self):
        return self.__bf

    @bf.setter
    def bf(self, bf):
        self.__bf = bf

    def __str__(self):
        return f"{self.age}岁的{self.name}带着他的男朋友{self.__bf.name}在夕阳下漫步"


class BoyFriend:
    def __init__(self, name, age):
        self.name = name
        self.age = age


class Person:
    def __init__(self, name, age):
        self.name = name
        self.age = age

    def buy_car(self, car):
        print(f"{self.name}给儿子买了{car.name}一台车")


class Car:
    def __init__(self, name, color):
        self.name = name
        self.color = color


wh = Student("王华", 34)
lp = BoyFriend("李鹏", 33)
wh.bf = lp
print(str(wh))

s7 = Car("SU7", "red")
p1=Person("XXX",67)
p1.buy_car(s7)
